<?php
/**
 * Application level Controller
 *
 * This file is application-wide controller file. You can put all
 * application-wide controller-related methods here.
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

App::uses('Controller', 'Controller');

/**
 * Application Controller
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package       app.Controller
 * @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
 */
App::uses('Utils', 'Lib');
App::uses('PaginadorHelper', 'Lib');
App::uses('Filtros_propiedades', 'Lib');
include('../Vendor/adodb5/adodb.inc.php');
include('../Vendor/php_mailer/class.phpmailer.php');

 class AppController extends Controller {
 


	public $helpers = array('Html', 'Session', 'Form', 'MenuBuilder.MenuBuilder');
		
		public $components = array(
			'Session',
			'Auth' => array(
				'loginRedirect' => array('controller' => 'propiedades', 'action' => 'index'),
				'logoutRedirect' => array('controller' => 'users', 'action' => 'logout')
			)
		);

		// public function isAuthorized($user) {
			// // Admin can access every action
			// if (isset($user['role']) && $user['role'] === 'admin') {
				// return true;
			// }
	
			// // Default deny
			// return false;
		// }		
		
		public function beforeFilter() {

			
			$this->set('userName', $this->Session->read("Auth.User.username"));
			$this->Auth->allow('index', 'view','display');
		 // Define your menu
			$menu = array(
				'main-menu' => array(
					array(
						'title' => __('Home'),
						'url' => array('controller' => 'pages', 'action' => 'home'),
					),
					array(
						'title' => __('About Us'),
						'url' => '/pages/about_us',
					),
					array(
						'title' => __('Branches'),
						'url' => '/pages/branches',
					),
					array(
						'title' => __('Contact'),
						'url' => '/pages/contact',
					),
				)
			);

			// For default settings name must be menu
			$this->set(compact('menu'));			
		}
}
